<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml"/>
    <xsl:param name="pathFile" select="'test'"/>
    <xsl:param name="logoFile"/>
    <xsl:param name="xmlUser"/>
    <xsl:variable name="userXML" select="document($xmlUser)"/>
    <xsl:template match="/">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="x" page-height="8.5in" page-width="11in"
								margin-top="0.5in" margin-bottom="0.5in" margin-left="1in" margin-right="1in">
                    <fo:region-before extent="1in" />
                    <fo:region-body margin-top="0.5in" margin-bottom="0.9in"/>
                    <fo:region-after extent="0.35in" />
                </fo:simple-page-master>
            </fo:layout-master-set>

            <fo:page-sequence master-reference="x">
                <fo:static-content flow-name="xsl-region-before">
                    <fo:block font-size="14pt" font-family="sans-serif" line-height="24pt" background-color="cyan"
						space-after.optimum="15pt" text-align="center" padding-top="3pt">
				Shipping Information
                    </fo:block>
                </fo:static-content>

                <fo:static-content flow-name="xsl-region-after">
                    <fo:block font-size="13pt" font-family="sans-serif" line-height="24pt"
                    background-color="black" space-after.optimum="15pt"
					color="white" text-align="center" padding-top="3pt">
                                                    Copyright © 2012 FPT University
                    </fo:block>
                </fo:static-content>

                <fo:flow flow-name="xsl-region-body">
                    <fo:block>
                        <fo:block>
                            <fo:external-graphic width="49px" height="49px">
                                <xsl:attribute name="src">
                                    <xsl:value-of select="$logoFile"/>
                                </xsl:attribute>
                            </fo:external-graphic>
                        </fo:block>
                        <fo:block padding="0.3in" margin-left="0.5in">
                        <fo:table border-collapse="separate" table-layout="fixed">
                            <fo:table-column column-width="6cm"/>
                            <fo:table-column column-width="12cm"/>
                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell>
                                        <fo:block font-size="13pt" >
                                            Customer Name:
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block>
                                            <xsl:value-of select="$userXML/customer/custName"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <fo:table-row>
                                    <fo:table-cell font-size="13pt" >
                                        <fo:block>
                                            Email :
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block>
                                            <xsl:value-of select="$userXML/customer/custEmail"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <fo:table-row>
                                    <fo:table-cell>
                                        <fo:block font-size="13pt" >
                                            Phone :
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block>
                                            <xsl:value-of select="$userXML/customer/custPhone"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <fo:table-row>
                                    <fo:table-cell>
                                        <fo:block font-size="13pt" >
                                            Address :
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block>
                                            <xsl:value-of select="$userXML/customer/custAddress"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </fo:table-body>
                        </fo:table>
                        </fo:block>
                        <fo:table border-collapse="separate" table-layout="fixed">
                            <fo:table-column column-width="2cm"/>
                            <fo:table-column column-width="5cm"/>
                            <fo:table-column column-width="5cm"/>
                            <fo:table-column column-width="4cm"/>
                            <fo:table-column column-width="3cm"/>
                            <fo:table-column column-width="4cm"/>

                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center" font-size="13pt" background-color="pink">
                                            No
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center" font-size="13pt" background-color="pink">
                                            Product Image
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center" font-size="13pt" background-color="pink">
                                            Product Name
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center" font-size="13pt" background-color="pink">
                                            Price
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center" font-size="13pt" background-color="pink">
                                            Quantity
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center" font-size="13pt" background-color="pink">
                                                Total
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <xsl:for-each select="carts/cart">
                                    <fo:table-row>
                                        <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                            <fo:block text-align="center" padding-top="17pt">
                                                <xsl:number level="single" count="cart"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                            <fo:block text-align="center">
                                                <fo:external-graphic width="49px" height="49px">
                                                    <xsl:attribute name="src">
                                                        <xsl:value-of select="concat($pathFile,image)"/>
                                                    </xsl:attribute>
                                                </fo:external-graphic>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                            <fo:block text-align="center" padding-top="17pt">
                                                <xsl:value-of select="name"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                            <fo:block text-align="center" padding-top="17pt">
                                                <xsl:value-of select="price"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                            <fo:block text-align="center" padding-top="17pt">
                                                <xsl:value-of select="quantity"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-color="gray" border-width="0.5pt" border-style="solid">
                                            <fo:block text-align="center" padding-top="18pt">
                                                <xsl:value-of select="format-number(subtotal, '#,###.00')"/> USD
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                </xsl:for-each>
                                <fo:table-row>
                                    <fo:table-cell>
                                        <fo:block text-align="center" padding-top="17pt">

                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block text-align="center">

                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block text-align="center" padding-top="17pt">

                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block text-align="center" padding-top="17pt">

                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block text-align="center" padding-top="17pt" font-size="13pt">
                                                Total Amount:
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block text-align="center" padding-top="18pt">
                                            <xsl:value-of select="format-number(sum(carts/cart/subtotal), '###,###.00')"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>

</xsl:stylesheet>
